import java.util.ArrayList;
import java.util.List;

public class Teacher {
    private final String teacherId;   // 教师编号
    private final String name;        // 教师姓名
    private final List<Course> courses; // 所授课程列表

    // 构造方法
    public Teacher(String teacherId, String name) {
        this.teacherId = teacherId;
        this.name = name;
        this.courses = new ArrayList<>();
    }

    // 教师开课
    public void offerCourse(Course course) {
        if (course != null && !courses.contains(course)) {
            courses.add(course);
            course.setTeacher(this);
            System.out.println(name + "老师成功开设课程: " + course.getCourseName());
        }
    }

    public String getName() {
        return name;
    }

    @Override
    public String toString() {
        return "教师编号: " + teacherId + ", 姓名: " + name;
    }
}
